<?php
/**
 * 上传
 * @author song
 */
class upload extends admin{
    public function __construct(){
        parent::__construct();
    }
    
    //上传文件
    public function index(){
        $type=trim($_POST['type']);//文件类型
        $sub=trim($_POST['type']);//文件子目录
        if(!$type) $type='common';
        if(!$sub) $sub=date('Ymd');
        $upload_path = C('UPLOAD_PATH').'/'.$type.'/'.$sub;//上传目录

        if(!is_dir($upload_path)) mkdir($upload_path,0700,true);
        
        $result=array();

        foreach ($_FILES as $k=> $v){
            $info=pathinfo($v['name']);
            $file_path=$upload_path.'/'.time().rand(1,1000).'.'.$info['extension'];
            if(move_uploaded_file($v["tmp_name"],$file_path)){
                $result[$k]=array('path'=>'http://www.saas.com/'.$file_path,'status'=>true);
            }else{
                $result[$k]=array('path'=>$file_path,'status'=>false);
            }
        }

       $this->ajaxReturn(array('status'=>1,'data'=>$result));
    }
}